# -*- coding:utf-8 -*-
'''
# Author: xiguan
# Mail: xiguan.teng@qq.com
# -----
# Last Modified: 2022-05-10 09:13:11
# Modified By: xiguan
# -----
# Copyright (c) 2022 XiGuan Inc.
# 
# No Bug No error No warning.
# -----
'''

from sqlalchemy import create_engine, Column, String, Integer
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

HOSTNAME = '127.0.0.1'
PORT = '3306'
DATABASE = 'ftp_server'
USERNAME = 'root'
PASSWORD = '123456'
DB_URL = 'mysql+mysqldb://{}:{}@{}:{}/{}'.format(USERNAME, PASSWORD, HOSTNAME, PORT, DATABASE)

engine = create_engine(DB_URL, echo=False)

# 所有的类都要继承自 declarative_base 这个函数生成的基类
Base = declarative_base(engine)

# 创建完和表映射的类后，还没有真正的映射到数据库当中，执行以下代码将类映射到数据库中，执行一次之后注释即可
# Base.metadata.create_all()

# 和数据库打交道的，是一个叫做Session的对象
Session = sessionmaker(bind=engine)
# 创建一个 Session 对象
db_session = Session()